import React from 'react'

export default function Content({list,setcheckOne,delid,calc}) {
  return (
    <React.Fragment>
     {list.map(item=>
            <div className="td" key={item.id}>
            <div className="checkall">
            <input
                  type="checkbox"
                  checked={item.checked}
                onChange={(e)=>{setcheckOne(item,e.target.checked)}}
                />
            </div>
                <div>{item.name}</div>
                <div>{item.price}</div>
                <div>
                    {item.num>1?<button className="reduce"  onClick={()=>{
                        calc(item.id,-1)
                    }}>-</button>:<button>-</button>}
                    <input  type='text'//num值
                     value={item.num} onChange={()=>{}}
                     />
                    <button className="add" onClick={()=>{
                        calc(item.id,1)
                    }}>+</button>
                </div>
                <div>{(item.price*item.num).toFixed(2)}</div>
                <div onClick={()=>{delid(item.id)}}>删除</div>
        </div>)}
    </React.Fragment>
  )
}
